import { userFileApi } from '@/request/api';
export default {
    namespaced: true,
    state: {
        cartTotal: 0,
        userInfo: {
            nickName: '--',
            coin: '0',
            headImg: require('@/assets/img/userImg.f8bbec5e.png'),
        },
    },
    getters: {},
    mutations: {
        UpdateUserInfo(state, payload) {
            console.log(payload);
            state.cartTotal = payload.cartTotal;
            state.userInfo = payload.userInfo;
        },
        initUserInfo(state, payload) {
            state.cartTotal = 0;
            state.userInfo = {
                nickName: '--',
                coin: '0',
                headImg: require('@/assets/img/userImg.f8bbec5e.png'),
            };
        },
    },
    actions: {
        async asyncUpdateUserInfo(context) {
            let res = await userFileApi();
            context.commit('UpdateUserInfo', res.data);
        },
    },
};
